<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function search(){
				var _uid=uid.value;
				if(!_uid.length){
					d1.innerHTML="用户编码不能为空";
					return;
				}
				var xhr=new XMLHttpRequest();
				xhr.open("GET",`/pro/v1/search/${_uid}`,true);
				xhr.onreadystatechange=function(){
					if(xhr.readyState==4&&xhr.status==200){
						
						var r=xhr.responseText;
						var arr=JSON.parse(r);
						//表头
						htmlStr=`
						  <table border="1">
						  	<tr>
						  		<th>用户昵称</th>
						  		<th>用户邮箱</th>
						  		<th>用户电话</th>
						  		<th>用户姓名</th>
						  		<th>用户性别</th>
						  	</tr>
						`;
						//循环
						var sex="不详";
						if(arr[0].gender==1){
							sex="男";
						}else if(arr[0].gender==0){
							sex="女";
						}else{
							sex="不详";
						}
						htmlStr+=`
						 <tr>
						 	<td>${arr[0].uname}</td>
						 	<td>${arr[0].email}</td>
						 	<td>${arr[0].phone}</td>
						 	<td>${arr[0].user_name}</td>
						 	<td>${sex}</td>
						 </tr>
						`;
						//表尾
						htmlStr+=`</table>`;
						// console.log(arr);
						d1.innerHTML=htmlStr;
					}
				}
				xhr.send();
			}
		</script>
	</head>
	<body>
		<input type="text" id="uid"><br>
		<button onclick="search()">查询</button>
		<div id="d1"></div>
		
		
	</body>
</html>
